<?php
import('@.Action.PublicAction');
class PrintAction extends Action
{
    function _initialize() 
    {
       if(!isset($_SESSION['user_right'])) {
			$this->redirect('login','Public');
        }
        parent::_initialize();
    }
    	
	function index()
	{	
		exit();
	}
	//班级花名册选择
	function printBjEveryoneIndex(){
		$Dao = D("CodeView");
		import("ORG.Util.HashMap");
		$maptmp=new HashMap();
		$maptmp->put("Comment.TABLE",array('eq',"studentinfo"));		
		$maptmp->put("Comment.FIELD",array('eq',"dm_bj"));
		if($_SESSION['dm_bj']){
			$maptmp->put("CODE.CODE",array('eq',$_SESSION['dm_bj']));
		}
		$voList = $Dao->findAll($maptmp);
		foreach ($voList as $tmp)
		{
			$list[]=array('bjh'=>$tmp['CODE'],'bjmc'=>$tmp['CODENAME']);
		}		
		$this->assign('list',$list);
		$this->display();	
	}	
	//班级花名册选择
	function printBjEveryone(){
		$Dao = D("CodeView");
		import("ORG.Util.HashMap");
		$maptmp=new HashMap();
		$maptmp->put("Comment.TABLE",array('eq',"studentinfo"));		
		$maptmp->put("Comment.FIELD",array('eq',"dm_bj"));
		$maptmp->put("CODE.CODE",array('eq',$_GET['dm_bj']));		
		$vo = $Dao->find($maptmp);
		$this->assign('vo',$vo);
		$Dao = D("Studentinfo");
		$maptmp=new HashMap();
		$maptmp->put("dm_bj",array('eq',$_GET['dm_bj']));		
		$voList = $Dao->findAll($maptmp);
		foreach ($voList as $tmp)
		{
			$list[]=array('xh'=>$tmp['xh'],'xm'=>$tmp['xm'],'xb'=>$tmp['xb']);
		}	
		$this->assign('list',$list);		
		$this->display();	
	}
	//班级领取物品表格
	function printBjListIndex(){
		$Model = new Model(); // 实例化一个model对象 没有对应任何数据表
		$sql = 'SELECT DISTINCT ('
        . ' substr('
        . ' bj, 1, 4'
        . ' )'
        . ' ) AS nj'
        . ' FROM `xtu_studentinfo` '
        . ' WHERE 1 =1'
        . ' ORDER BY nj ASC ';
		$list=$Model->query($sql);

		$this->assign('list',$list);	
		$this->display();	
	}			
	//班级领取物品表格
	function printBjList(){
		$Model = new Model(); // 实例化一个model对象 没有对应任何数据表
		$sql="SELECT bj, count( * ) AS num FROM `xtu_studentinfo` WHERE 1 =1  AND substr( bj, 1, 4 ) =".$_GET['nj']." GROUP BY bj";	
		$list=$Model->query($sql);
		$this->assign('list',$list);	
		$this->display();	
	}	
	//学生证明主页面（输入内容）
	function printZhengmingIndex(){
		$this->display();	
	}	
	//学生证明
	function printZhengming(){
		$Dao = D("Studentinfo"); 
		if(empty($_POST["xh"])){
			$this->assign("jumpUrl",__URL__."/printZhengmingIndex"); 
			$this->error("学号不能为空！"); 
		}
		$vo = $Dao->find("xh=".$_POST["xh"]); 
		if($vo === false) 
		{ 
			$this->assign("jumpUrl",__URL__."/printZhengmingIndex"); 
			$this->error("没有该学号学生信息！"); 
		}
		$this->assign('vo',$vo); 
		$this->display();	
	}		
}
?>